How coral reefs protect coastlines